/* radkit developer UI styles
 * Focused on a restrained enterprise aesthetic with light/dark modes.
 */

:root {
  color-scheme: dark;

  /* Typography */
  --font-sans: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  /* Color tokens (dark default) */
  --bg-app: #0f1520;
  --bg-surface: #171d29;
  --bg-muted: #1f2533;
  --bg-hover: #222a3b;
  --border-subtle: #273043;
  --border-strong: #3a455c;
  --shadow-soft: 0 12px 28px rgba(7, 11, 19, 0.35);

  --text-strong: #eef1ff;
  --text-body: #c6ccdc;
  --text-muted: #8d97aa;
  --text-faint: #6a7386;

  --accent: #3d7cff;
  --accent-soft: rgba(61, 124, 255, 0.14);
  --accent-contrast: #0f1726;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg-app: #f5f6fb;
  --bg-surface: #ffffff;
  --bg-muted: #f0f2f8;
  --bg-hover: #e7eaf3;
  --border-subtle: #dde1ec;
  --border-strong: #c5ccdb;
  --shadow-soft: 0 12px 32px rgba(17, 23, 36, 0.12);

  --text-strong: #121826;
  --text-body: #1f2738;
  --text-muted: #4f5a6d;
  --text-faint: #6d7585;

  --accent: #1f64f2;
  --accent-soft: rgba(31, 100, 242, 0.1);
  --accent-contrast: #ffffff;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg-app: #f5f6fb;
    --bg-surface: #ffffff;
    --bg-muted: #f0f2f8;
    --bg-hover: #e7eaf3;
    --border-subtle: #dde1ec;
    --border-strong: #c5ccdb;
    --shadow-soft: 0 12px 32px rgba(17, 23, 36, 0.12);

    --text-strong: #121826;
    --text-body: #1f2738;
    --text-muted: #4f5a6d;
    --text-faint: #6d7585;

    --accent: #1f64f2;
    --accent-soft: rgba(31, 100, 242, 0.1);
    --accent-contrast: #ffffff;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg-app);
  color: var(--text-body);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
}

/* Layout ------------------------------------------------------- */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem clamp(1.6rem, 4vw, 3rem);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.1rem;
}

.brand__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-strong);
  letter-spacing: -0.01em;
}

.brand__badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 0.28rem 0.85rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.app__main {
  width: 100%;
  flex: 1 1 auto;
  padding: 2.5rem clamp(1.6rem, 4vw, 3rem) 3.5rem;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.app__footer {
  padding: 1.25rem clamp(1.2rem, 3vw, 2.5rem);
  border-top: 1px solid var(--border-subtle);
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stack--tight {
  gap: 0.6rem;
}

.stack--loose {
  gap: 1.5rem;
}

.cluster {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.cluster--wrap {
  flex-wrap: wrap;
}

.cluster--between {
  justify-content: space-between;
  width: 100%;
}

.cluster--gap-sm {
  gap: 0.4rem;
}

.section-label {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.headline {
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-strong);
}

.body {
  font-size: 0.95rem;
  line-height: 1.55;
}

.body-sm {
  font-size: 0.85rem;
  line-height: 1.4;
}

.muted {
  color: var(--text-muted);
}

.mono {
  font-family: var(--font-mono);
}

/* Panels ------------------------------------------------------- */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 1.5rem;
  box-shadow: none;
}

.panel--dense {
  padding: 1rem;
}

.panel--inset {
  background: var(--bg-muted);
}

.panel--placeholder {
  background: var(--bg-muted);
  border: 1px dashed var(--border-subtle);
  min-height: 260px;
}

.panel:hover {
  border-color: var(--border-strong);
}

.stat-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat__label {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.stat__value {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-strong);
}

/* Buttons + toggles ------------------------------------------- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: 5px;
  border: 1px solid var(--border-subtle);
  background: transparent;
  font-size: 0.9rem;
  font-weight: 500;
  transition: border-color 120ms ease, background 120ms ease;
}

.button:focus-visible {
  outline: 2px solid transparent;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(61, 124, 255, 0.25);
}

.button--primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-contrast);
}

.button--primary:hover {
  background: #356de0;
}

:root[data-theme="light"] .button--primary:hover {
  background: #1a56c8;
}

.button--ghost {
  background: transparent;
  color: var(--text-body);
}

.button--ghost:hover {
  background: var(--bg-hover);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.95rem;
  border-radius: 5px;
  border: 1px solid var(--border-subtle);
  background: transparent;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-body);
}

.theme-toggle:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.theme-toggle__icon {
  width: 1rem;
  height: 1rem;
  display: block;
}

.theme-toggle__label {
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.theme-toggle__icon--dark {
  display: none;
}

[data-theme="dark"] .theme-toggle__icon--dark {
  display: block;
}

[data-theme="dark"] .theme-toggle__icon--light {
  display: none;
}

[data-theme="light"] .theme-toggle__icon--light {
  display: block;
}

[data-theme="light"] .theme-toggle__icon--dark {
  display: none;
}

/* Lists + tables ---------------------------------------------- */
.card-list.card-list--agents {
  display: grid;
  gap: 1.1rem;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  max-width: 960px;
}

.card-list.card-list--skills {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.agent-card {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.agent-card__meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.endpoint-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-left: 0;
  margin: 0;
  list-style: none;
}

.endpoint {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  border-left: 2px solid var(--border-subtle);
  padding-left: 0.85rem;
}

.endpoint__title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-strong);
}

.endpoint__url {
  font-size: 0.82rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  word-break: break-word;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  padding: 0.25rem 0.65rem;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.accordion {
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-muted);
  padding: 0.75rem 1rem;
}

.accordion__summary {
  list-style: none;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-body);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.accordion__summary::after {
  content: "▾";
  color: var(--text-muted);
  transition: transform 120ms ease;
}

.accordion[open] .accordion__summary::after {
  transform: rotate(180deg);
}

.accordion__list {
  margin: 0.6rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.84rem;
  color: var(--text-body);
  line-height: 1.45;
}

.detail-layout {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.detail-layout__main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.detail-layout__sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Console ------------------------------------------------------ */
.agent-console {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.console-form {
  background: var(--bg-muted);
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  padding: 1.1rem 1.25rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.field__control {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
  color: var(--text-body);
  font: inherit;
}

.field__control:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

.field__control--multiline {
  resize: vertical;
  min-height: 6rem;
}

.console-stream {
  background: var(--bg-muted);
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  padding: 1.2rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.console-stream--message {
  border-style: dashed;
}

.console-stream--error {
  border-color: #ce3b4c;
  background: rgba(206, 59, 76, 0.08);
}

.console-stream__initial {
  display: grid;
  gap: 0.6rem;
}

[data-stream-output] {
  max-height: 12rem;
  overflow-y: auto;
  display: grid;
  gap: 0.6rem;
  padding-right: 0.35rem;
}

.stream-entry {
  border-left: 3px solid var(--border-subtle);
  padding-left: 0.7rem;
  display: grid;
  gap: 0.3rem;
}

.stream-entry--status {
  border-color: var(--accent);
}

.stream-entry__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stream-entry__label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-body);
  text-transform: capitalize;
}

.stream-entry__body {
  color: var(--text-body);
}

.console-contexts {
  display: grid;
  gap: 1rem;
}

.console-context {
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-muted);
  padding: 1rem 1.1rem;
  display: grid;
  gap: 0.9rem;
}

.console-context--highlight {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}

.console-context__header {
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.6rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.console-context__negotiation {
  background: var(--bg-surface);
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  padding: 0.7rem 0.85rem;
}

.console-context__messages {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.console-message {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
}

.console-message__role {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
}

.console-message__text {
  color: var(--text-body);
  font-size: 0.85rem;
}

.console-task {
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  padding: 0.85rem 1rem;
  display: grid;
  gap: 0.8rem;
}

.console-task__header {
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.6rem;
}

.console-task__section {
  display: grid;
  gap: 0.5rem;
}

.console-task__artifacts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.artifact-card {
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.5rem 0.7rem;
  background: var(--bg-muted);
  display: grid;
  gap: 0.2rem;
}

.artifact-card--update {
  border-style: dashed;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 2px solid var(--border-subtle);
}

.timeline__item {
  position: relative;
  padding-left: 1.1rem;
  margin-left: -0.1rem;
  margin-bottom: 0.7rem;
}

.timeline__item:last-child {
  margin-bottom: 0;
}

.timeline__marker {
  position: absolute;
  top: 0.25rem;
  left: -6px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.timeline__label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-body);
  text-transform: capitalize;
}

.timeline__timestamp {
  font-size: 0.72rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.7rem;
  color: var(--accent);
  background: var(--accent-soft);
}

.status-pill--complete {
  color: #36c691;
  background: rgba(54, 198, 145, 0.12);
}

.status-pill--failed {
  color: #ce3b4c;
  background: rgba(206, 59, 76, 0.18);
}

.status-pill--rejected {
  color: #d48632;
  background: rgba(212, 134, 50, 0.16);
}

.status-pill--input {
  color: #3d7cff;
  background: rgba(61, 124, 255, 0.14);
}

.status-pill--working {
  color: var(--accent);
  background: var(--accent-soft);
}

.status-pill--submitted {
  color: var(--text-muted);
  background: rgba(141, 151, 170, 0.18);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border-subtle);
  border-radius: 5px;
  padding: 1.5rem;
  background: var(--bg-muted);
}

/* HTMX states -------------------------------------------------- */
.hx-loading {
  opacity: 0.6;
  transition: opacity 120ms ease;
}

.hx-error {
  border-color: #ce3b4c;
}

@media (max-width: 720px) {
  .app__header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.8rem;
  }

  .app__main {
    width: calc(100% - 2rem);
    padding-top: 1.8rem;
    padding-bottom: 2.5rem;
  }

  .stack {
    gap: 0.9rem;
  }
}

@media (max-width: 960px) {
  .detail-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
